package com.igeekhome.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.igeekhome.biz.IAttendanceStatisticsService;
import com.igeekhome.biz.ICustomerInfoService;
import com.igeekhome.biz.ICustomerServiceService;
import com.igeekhome.pojo.AttendanceStatistics;
import com.igeekhome.pojo.CustomerService;
import com.igeekhome.pojo.WorkloadStatistics;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 * 考勤表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-03-16
 */
@Controller
@RequestMapping("/attendanceStatistics")
public class AttendanceStatisticsController {

    @Autowired
    private IAttendanceStatisticsService iAttendanceStatisticsService;

    @RequestMapping("/kaoqing")
            public String kaoqing(HttpSession session,Model model, @RequestParam("value")String value, @RequestParam("current")Integer current, @RequestParam("size")Integer size){
        IPage<AttendanceStatistics> page =new Page<>(current,size);

        QueryWrapper<AttendanceStatistics> qw=new QueryWrapper<>();
        qw.like("nickname",value).or().like("id", value).or().like("logintime", value).or().like("freetime", value).or().like("busytime",value).or().like("onlinetime",value).or().like("offlinetime",value);

        IPage<AttendanceStatistics> page1=iAttendanceStatisticsService.page(page,qw);
        List<AttendanceStatistics> list = page1.getRecords();

        session.setAttribute("kaoqingCount",this.iAttendanceStatisticsService.count());

        long pagesCount=page1.getPages();
        model.addAttribute("list",list);
        model.addAttribute("pagesCount",pagesCount);

        return "kaoqingbiao";

            }
//    @RequestMapping("/search")
//    public String search(Model model, String value){
//        QueryWrapper<AttendanceStatistics> qw=new QueryWrapper<>();
////        qw.like("realname",value);
//        qw.like("nickname",value).or().like("id", value).or().like("logintime", value).or().like("freetime", value).or().like("busytime",value).or().like("onlinetime",value).or().like("offlinetime",value);
//        List<AttendanceStatistics> list=iAttendanceStatisticsService.list(qw);
//        model.addAttribute("list",list);
//
//        return "kaoqingbiao";
//    }
//
}

